<?php
require_once("../config.php");
$fromwhere=$_SERVER['HTTP_REFERER'];
if(!isset($_POST)) exit("no way");//header("location:$fromwhere");
$post_a=array();
$post_a=$_POST;
//var_dump($post_a);
foreach ($post_a as $value)
{
	$dsql->SetQuery("SELECT file,userid FROM pic  WHERE productid = ".$value);
	$dsql->Execute();
	$allfiles=array();
	$userid=array();
	while($row=$dsql->GetArray())
	{
		$allfiles[]=$row['file'];
		$userid[]=$row['userid'];
	}	
	foreach($allfiles as $k=>$file)
	{
		$username=$dsql->getone("select username from backuser where id = ".$userid[$k]);
		//echo $username;//
		rename(PICDIR.$username."/done/".$file,PICDIR."done/".$file);
	}

	$uid=new UID();
	$data=array("status"=>"on");
	$condition="id = ".$value;
	$uid->update("product",$data,$condition);
}
header("location:$fromwhere");

?>